# **********************OBJ INFO**************************
# Author:YuKalix
# @Time    : 2020-4-17 17:45
# @Site    : 52ziyu.cn
# @File    : test.py
# @software: PyCharm
# *********************************************************

# **********************OBJ INFO**************************
# Author:YuKalix
# @Time    : 2019-9-20 17:35
# @Site    : 52ziyu.cn
# @File    : TouchSensor.py
# @software: PyCharm
# *********************************************************

import RPi.GPIO as GPIO
import time


class TouchSensor:
    def __init__(self):
        # SIG针脚数,这里为14可见图
        self.touch_pin_num = 14
        self.led_pin_num = 17
        # 设置编程引脚模式
        GPIO.setmode(GPIO.BCM)

    def main(self):



        GPIO.setup(self.led_pin_num, GPIO.OUT)
        GPIO.setup(self.touch_pin_num, GPIO.IN)

        if GPIO.input(self.touch_pin_num) == 1:
            # 成功触发LED灯
            GPIO.output(self.led_pin_num, GPIO.HIGH)
            # 给led初始化
            time.sleep(1)
            GPIO.output(self.led_pin_num, GPIO.LOW)
            GPIO.setup(self.touch_pin_num, GPIO.IN)

            return 1
        return 0


if __name__ == '__main__':
    S = TouchSensor()
    while True:
        result = S.main()
        print(result)



